package br.com.consignum.view;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import br.com.consignum.dto.request.LoginRequestDTO;
import br.com.consignum.negocio.LoginBO;

public class LoginActivity extends Activity {

    private LoginRequestDTO loginRequestDTO;
    private LoginBO loginBO;

    protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.login_activity);
	clickLogar();
    }

    private void clickLogar() {

	Button button = (Button) findViewById(R.id.login_activity_logar);

	button.setOnClickListener(new OnClickListener() {

	    public void onClick(View view) {

		EditText login = (EditText) findViewById(R.id.login_activity_login);
		EditText senha = (EditText) findViewById(R.id.login_activity_senha);
		EditText idParceiro = (EditText) findViewById(R.id.login_activity_id_parceiro);
		EditText numConsignataria = (EditText) findViewById(R.id.login_activity_numero_uf);

		loginRequestDTO = new LoginRequestDTO(Long.parseLong(idParceiro.getText().toString()), new String(login.getText().toString()), new String(senha.getText().toString()), Long.parseLong(numConsignataria.getText().toString()));
		
		loginBO = new LoginBO();
		loginBO.logar(loginRequestDTO);

	    }
	});

    }
}
